﻿@model KPIS.GERP.Models.ICM.InventoryStockTakingItem

@{
    int StockTakingId = ViewBag.StockTakingId;
    int ResItemId = ViewBag.ResItemId;
    int SumAmountStock = ViewBag.SumAmountStock;
    
    var service = new KPIS.GERP.WEB.GIMS.PurchaseCheckAssetService.PurchaseCheckAssetServiceClient();
    var modelStockTaking = service.SelectInventoryStockTaking(new InventoryStockTaking { StockTakingId = StockTakingId, RecordStatus = "!" + RecordStatus.DeletedStatus }, new[] { "JobSite", "Warehouse", "MasResourceType" }).FirstOrDefault();
    var modelResource = (dynamic)null;
       
    // List ของสถานะการใช้งาน
    SelectListItem[] StatusSelectList = null;

    string ResourceType = modelStockTaking.MasResourceType.Name;
    string ResourceName = string.Empty;
    string ResourceCode = string.Empty;

    if (ResourceType == "วัสดุ")
    {
        modelResource = service.SelectOfficeSuppliesLots(new OfficeSuppliesLot { ResItemId = ResItemId, RecordStatus = "!" + RecordStatus.DeletedStatus }, new[] { "MasResourceItem" }).FirstOrDefault();
        if (modelResource != null)
        {
            ResourceName = modelResource.MasResourceItem.Name;
            ResourceCode = modelResource.MasResourceItem.Code;
        }

        StatusSelectList = service.SelectListStatus(KPIS.GERP.Models.ICM.IcmMasLookUpType.LookUpType.OfficeSupplyLotStatus);
    }
    else if (ResourceType == "ครุภัณฑ์")
    {
        modelResource = service.SelectAssets(new Asset { ResItemId = ResItemId, RecordStatus = "!" + RecordStatus.DeletedStatus }, new[] { "MasResourceItem" }).FirstOrDefault();
        if (modelResource != null)
        {
            ResourceName = modelResource.MasResourceItem.Name;
            ResourceCode = modelResource.MasResourceItem.Code;
        }

        StatusSelectList = service.SelectListStatus(KPIS.GERP.Models.ICM.IcmMasLookUpType.LookUpType.AssetStatus);
    }
        
}

<div class="widget-box">
	<div class="widget-header header-color-blue2">
        <h4 class="lighter smaller">เพิ่มรายการตรวจนับพัสดุ</h4>
    </div>
    <div class="widget-body">
        <div class="widget-body-inner">
			<div class="widget-main ">
                
                <div class="control-group">
                    <div class="control-label">
                        ประเภทพัสดุ : 
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.Label(ResourceType)
                    </div>
                </div>
                
                <div class="control-group">
                    <div class="control-label">
                       รายการ :
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.Label(ResourceName)
                        @Html.HiddenFor(model => model.ResItemId, new { Value = ResItemId })
                        @Html.HiddenFor(model => model.StockTakingId, new { Value = StockTakingId })
                        @Html.HiddenFor(model => model.QuanlityAmountStock, new { Value = SumAmountStock })
                    </div>
                </div>

                <div class="control-group">
                    <div class="control-label">
                        หมายเลข :
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.Label(ResourceCode)
                    </div>
                </div>
                
                <div class="control-group">
                    <div class="control-label">
                       จำนวนที่นับได้ :
                    </div>
                    <div class="controls">
                        @Html.TextBoxFor(model => model.QuantityAmountReal, new { id = "txtQtyAmountReal" })
                    </div>
                </div>

                <div class="control-group">
                    <div class="control-label">
                        สถานะการใช้งาน :
                    </div>
                    <div class="controls">
                        @Html.DropDownListFor(model => model.StatusParcel, StatusSelectList, new { @class = "chzn-select input-xlarge", data_placeholder = "เลือกสถานะการใช้งาน..." })
                    </div>
                </div>
                    
                <div class="control-group">
                    <div class="control-label">
                        หมายเหตุ :
                    </div>
                    <div class="controls">
                        @Html.TextAreaFor(model => model.Remark)
                    </div>
                </div>     

            </div>
        </div>
    </div>
</div>